package com.manager.config.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manager.config.mapper.CountryMapper;
import com.manager.config.service.CountryService;


import com.manager.model.model.Country;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author pooh
* @description 针对表【country】的数据库操作Service实现
* @createDate 2023-03-19 12:45:43
*/
@Service
public class CountryServiceImpl extends ServiceImpl<CountryMapper, Country>
    implements CountryService {

    @Autowired
    CountryMapper countryMapper;
    @Override
    public boolean addCountry(String content) {
        Country country = countryMapper.searchByName(content);
        if(country == null){
            Country country1 = new Country();
            country1.setStatus(1);
            country1.setName(content);
            this.save(country1);
        }else {
            if(country.getStatus() == 0){
                country.setStatus(1);
                this.updateById(country);
            }else {
                return false;
            }
        }
        return true;
    }
}




